package com.hspedu.set_;

/**
 * @author DL5O
 * @version 1.0
 */
@SuppressWarnings("all")
public class HashSetStructure {
    public static void main(String[] args) {
        //模拟一个HashSet的底层 (HashMap 的底层结构)

        //1.创建一个数组，数组的类型是Node[]
        //2.直接把Node[] 数组称为表
        Node[] table = new Node[16];
        System.out.println("table=" + table);

        //3.创建节点
        Node john = new Node("john", null);
        Node jack = new Node("jack",null);
        Node rose = new Node("Rose", null);
        john.next = jack;
        jack.next = rose;
        table[2] = john;

        Node lucy = new Node("lucy",null);
        table[3] = lucy; //luc 放到table表的索引为3的位置
        System.out.println("table=" + table);
    }
}

class Node{//节点用来存放数据，可以指向下一个节点，从而形成链表
    Object item; //存放数据
    Node next;  //指向下一个节点

    public Node(Object item, Node next) {
        this.item = item;
        this.next = next;
    }
}